ErrorEntry

sealed interface ErrorEntry

Error context stored in a ValidationResult. This can represent an errored or non-errored state, can include multiple children contexts, and can include non-textual information (see ValidationResult.Errors.ACTION for example)

All Validation Results include an error entry; starting with a NonErrorEntry by default for a successful (non-errored) result.

Author

fzzyhmstrs

Since

0.7.0

Types

Link copied to clipboard
class Builder<C : Any>

Builds error entries. This is used in the UnaryOperator pattern seen in several places in this class, but can be used "freely" with builder

Link copied to clipboard
object Companion
Link copied to clipboard
sealed interface Entry<C : Any>

Represents the actual content stored within an error entry. This is used as a buffer between the error entry and code-facing interactions with it

Link copied to clipboard

A mutable wrapper of an error entry. This is typically used to provide an "entrypoint" for building errors based on a pre-defined header message. Use it with other validation results by calling ValidationResult.attachTo, and then build your final compound result with ValidationResult.ofMutable

Link copied to clipboard
class Type<C : Any>(val name: String, val isString: Boolean = true, val isLoggable: Boolean = true, val isError: Boolean = true)

Type class representing a certain category of error content. This styles logged lines and can be used to store non-string content information.

Functions

Link copied to clipboard

Adds another error entry using ValidationResult.Errors.BASIC as the type, as a child to this one, using the builder to build that entry. Entries are immutable, so the updated entry is returned. The entry this is called on is not changed.

Adds another error entry as a child to this one. Entries are immutable, so the updated entry is returned. The entry this is called on is not changed.

Adds another error entry of the given type as a child to this one, using the builder to build that entry. Entries are immutable, so the updated entry is returned. The entry this is called on is not changed.

Link copied to clipboard

Performs the provided consumer action on this and any children entries.

Link copied to clipboard

Performs the provided consumer action on this and any children entries if they are of the provided type.

Link copied to clipboard
abstract fun getPlainString(): String

Return the string representation of the logging for this entry without extra styling and type information.

Link copied to clipboard
abstract fun getString(): String

Returns the string representation of the logging for this entry

Link copied to clipboard

Whether this entry or one or more of its children is of the given type

Link copied to clipboard
abstract fun isCritical(): Boolean

Whether this entry contains a critical error. It will have one or more exceptions attached to it

Link copied to clipboard
open fun isEmpty(): Boolean

Whether this entry is empty. An empty error is non-errored

Link copied to clipboard
abstract fun isError(): Boolean

Whether the entry contains an errored state. This is usually true for textual error types, false for empty entries or entries containing non-text information.

Link copied to clipboard
abstract fun isLoggable(): Boolean

Whether this entry is loggable. Entries with a non-text type generally aren't.

Link copied to clipboard

Provides an Iterable containing this and any children entries.

Link copied to clipboard

Provides an Iterable containing this and any children entries as applicable based on the provided type.

Link copied to clipboard
open fun log(writer: BiConsumer<String, Throwable?>)

Logs this entry with the provided writer

Link copied to clipboard
open fun logPlain(writer: BiConsumer<String, Throwable?>)

Logs this entry with the provided writer using plain content information

Link copied to clipboard

Converts this entry to a Mutable

Link copied to clipboard

Performs the provided predicate test on this and any children entries. Generally returns true on the first success.

Link copied to clipboard

Performs the provided predicate test on this and any children entries if they are of the provided type. Generally returns true on the first success.